<?php

require_once 'FDefaultController.class.php';

abstract class FModel
{
    
    private $name;
    
    protected $title;
    protected $controller;

    public function __construct($name)
    {
        $this->name = $name;
        $controller = $this->name . 'Controller';
        
        if ( class_exists($controller) )
        {
            $this->controller = new $controller();            
        }
        else
        {
            $this->controller = new FDefaultController();
        }
        
        $this->controller->setTable($this->name);
        $this->controller->setModel($this->name);
    }
    
    abstract function getForm();
    
    public function setControllerTable($tableName)
    {
        $this->controller->setTable($tableName);
    }
    
    public function getName() {
        return $this->name;
    }

    public function setName($name) {
        $this->name = $name;
    }
       
    public function getTitle() {
        return $this->title;
    }

    public function setTitle($title) {
        $this->title = $title;
    }

    public function getController() {
        return $this->controller;
    }

    public function setController($controller) {
        $this->controller = $controller;
    }

}

?>
